
#include "register/op_def_registry.h"
#include "spence_tiling.h"
#include "tiling_common.h"
int64_t get_type_additon(ge::DataType dtype)
{
    return 20;
}
namespace optiling
{
static ge::graphStatus TilingFunc(gert::TilingContext *context)
{
    SpenceTilingData tiling;
    set_size_by_input(tiling, context, 0);
    CommonTiling<SpenceTilingData> commonTiling;
    commonTiling.tiling = &tiling;
    commonTiling.context = context;
    commonTiling.data_size = tiling.get_size();
    commonTiling.vector_align_size = 256;
    commonTiling.mem_addition = get_type_additon;
    commonTiling.apply();
    tiling_save_to_buffer(tiling, context);
    tiling_zero_workspace(context);
    print_common_tiling(tiling);
    return ge::GRAPH_SUCCESS;
}
} // namespace optiling

namespace ge
{
static ge::graphStatus InferShape(gert::InferShapeContext *context)
{
    const gert::Shape *x1_shape = context->GetInputShape(0);
    gert::Shape *y_shape = context->GetOutputShape(0);
    *y_shape = *x1_shape;
    return GRAPH_SUCCESS;
}
} // namespace ge

namespace ops
{
class Spence : public OpDef
{
  public:
    explicit Spence(const char *name) : OpDef(name)
    {
        this->Input("x")
            .ParamType(REQUIRED)
            .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
            .Format({ge::FORMAT_ND, ge::FORMAT_ND})
            .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});
        this->Output("y")
            .ParamType(REQUIRED)
            .DataType({ge::DT_FLOAT, ge::DT_FLOAT16})
            .Format({ge::FORMAT_ND, ge::FORMAT_ND})
            .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND});

        this->SetInferShape(ge::InferShape);

        this->AICore().SetTiling(optiling::TilingFunc);
        this->AICore().AddConfig("ascend310b");
    }
};

OP_ADD(Spence);
} // namespace ops
